// 导入用户集合
const { Collection } = require('../../../model/collection');
const { CollectionCategory } = require('../../../model/collectionCategory');

module.exports = async (req, res) => {
  Collection.create(req.body).then(async item => {
      const cate = await CollectionCategory.findOne({_id: item.category})
        
    res.json({
        data: {...JSON.parse(JSON.stringify(item)), category: cate},
        message: '添加成功！'
    })
  }).catch((err) => {
    res.status(403)
    res.json({
        log: err,
        message: '添加失败！'
    })
  })
}